#include<bits/stdc++.h>
#define sd(n) scanf("%d",&n) 
#define sld(n) scanf("%lld",&n)
#define pd(n) printf("%d", (n))
#define pld(n) printf("%lld", n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fi first
#define se second
const int N=2e5;
const int maxn=1e6;
typedef long long int ll;
using namespace std;
//----------------------------------------------------------------------------//

void solve()
{
	int n;
	sd(n);
	string s1;
	cin>>s1;
	string ans="";
	ans+=s1[0];
	if(s1[0]==s1[1]||s1[1]>s1[0])
	{
		cout<<ans;
		reverse(all(ans));
		cout<<ans;
		puts("");
		return;
	}
	else
	{
		for(int i=1;i<s1.size();i++)
		{
			if(s1[i]<=s1[i-1]) ans+=s1[i];//后小于前	
			else break;
		}		
	}
	cout<<ans;
	reverse(all(ans));
	cout<<ans;
	puts("");
}

int main()
{
	int T;
	sd(T);
	while (T--)
	{
		solve();
	}
	return 0;
}